package com.freesky.biz.citic.controller;

import com.freesky.biz.citic.domain.TCiticLucky;
import com.freesky.biz.citic.service.ICiticLuckyService;
import com.freesky.biz.icbc.domain.TAigouFriday;
import com.freesky.biz.icbc.service.IAigouFridayService;
import com.freesky.common.annotation.Log;
import com.freesky.common.annotation.RepeatSubmit;
import com.freesky.common.core.controller.BaseController;
import com.freesky.common.core.domain.AjaxResult;
import com.freesky.common.core.page.TableDataInfo;
import com.freesky.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 中信信运抢券
 */
@RestController
@RequestMapping("/citic/lucky")
public class CiticLuckyController extends BaseController {

    @Autowired
    private ICiticLuckyService citicLuckyService;

    /**
     * 信运抢券列表
     */
    @PreAuthorize("@ss.hasPermi('citic:lucky:list')")
    @GetMapping("/list")
    public TableDataInfo list(TCiticLucky citicLucky) {
        startPage();
        List<TCiticLucky> list = citicLuckyService.findList(citicLucky);
        return getDataTable(list);
    }

    @Log(title = "信运抢券", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('citic:lucky:export')")
    @GetMapping("/export")
    public AjaxResult export(TCiticLucky citicLucky,
                             HttpServletResponse response) {
        return citicLuckyService.exportFile(citicLucky);
    }

    @Log(title = "信运抢券", businessType = BusinessType.UPDATE)
    @PreAuthorize("@ss.hasPermi('citic:lucky:edit')")
    @RepeatSubmit
    @PostMapping("/updateRechargeById")
    public AjaxResult updateRechargeById(@Validated @RequestBody TCiticLucky citicLucky,
                             HttpServletResponse response) {
        citicLucky.setProcessed("4");
        citicLuckyService.updateRechargeById(citicLucky.getProcessed(),citicLucky.getId());
        return AjaxResult.success();
    }
}
